﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using IndoReputation.Models.BusinessObject;
using IndoReputation.Models.BusinessObject.Collections;
using IndoReputation.Models.DataAccess;

namespace IndoReputation.Models.BusinessLogic
{
    public class NewsValuesBOL
    {
        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 4/22/2012  6:03 PM
        /// Todo: Insert an newsValues to db
        /// </summary>
        /// <param name="newsValues">The newsValues.</param>
        /// <returns></returns>
        public static int Insert(NewsValues newsValues)
        {
            try
            {
                newsValues.CreateAt = DateTime.Now;
                newsValues.CreateBy = MySession.UserID;
                newsValues.UpdateAt = null;
                newsValues.UpdateBy = null;
                return NewsValuesDAL.Insert(newsValues);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  9:45 AM
        /// Todo: Update a User Exists in Database 
        /// </summary>
        /// <param name="newsValues">A newsValues.</param>
        /// <returns></returns>
        public static bool Update(NewsValues newsValues)
        {
            try
            {
                newsValues.UpdateAt = DateTime.Now;
                newsValues.UpdateBy = MySession.UserID;
                return NewsValuesDAL.Update(newsValues);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  10:36 AM
        /// Todo: Delete a User Existst in Database
        /// </summary>
        /// <param name="newsValues">A newsValues.</param>
        /// <returns></returns>
        public static bool Delete(int newsValuesID)
        {
            try
            {
                return NewsValuesDAL.Delete(newsValuesID);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/29/2011  5:23 PM
        /// Todo: Get All NewsValues
        /// </summary>
        /// <returns></returns>
        public static NewsValuesList GetAllNewsValues()
        {
            try
            {
                return NewsValuesDAL.GetAllNewsValues() ?? new NewsValuesList();
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  10:40 AM
        /// Todo: Select a User existst in Database
        /// </summary>
        /// <param name="newsValuesID">The newsValues ID.</param>
        /// <returns></returns>
        public static NewsValues GetNewsValuesById(int newsValuesID)
        {
            try
            {
                return NewsValuesDAL.GetNewsValuesById(newsValuesID);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        public static List<NewsValuesJoin> GetAllNewsValuesJoinByNewsID(int newsID)
        {
            try
            {
                return NewsValuesDAL.GetAllNewsValuesJoinByNewsID(newsID);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }
    }
}